using System;
using UnityEngine;

public class StarPickup : MonoBehaviour
{

	private float bounceOffset;
	private Vector3 originalPosition;
	
	GameObject energyLight;
	
	public void Start()
	{
		bounceOffset = UnityEngine.Random.value * 37.2f;
		originalPosition = transform.position;
		energyLight = new GameObject("Energy Light"); 
		energyLight.AddComponent("Light");
		energyLight.transform.position = transform.position;
		energyLight.light.color = Color.yellow;
		energyLight.light.range = 600.0f;
		energyLight.light.intensity = 0.8f;
		
		this.renderer.material.shader = Shader.Find("Toon/Lighted Outline");
	}
	
	public Vector3 getPosition()
	{
		return transform.position;
	}
	
	public void Update()
	{
		transform.Rotate(new Vector3(0.0f, Time.deltaTime * 90.0f, 0.0f));
		transform.position = originalPosition + new Vector3(0.0f, 11.0f * (float)Math.Sin(bounceOffset + Time.timeSinceLevelLoad*3.0f)  , 0.0f);
	
		if (energyLight.transform)
			energyLight.transform.position = transform.position;
		
	}

}